/* CheckGarbageCollection.java Created on 13/giu/2012 */
package it.tommasocortonesi.scjp.cap4;

import java.util.Date;

/**
 * Classe test per GarbageCollection
 *
 * @author 		tommasocortonesi
 * @version 	1.0, 13/giu/2012
 */
public class CheckGarbageCollection {

	public static void main(String[] args) {
		Runtime rt = Runtime.getRuntime();
		System.out.println("Total JVM memory: " + rt.totalMemory());
		System.out.println("Before free memory: " + rt.freeMemory());
		
		Date d = null;
		for (int i = 0; i < 10000; i++) {
			d = new Date();
//			System.out.println("After free memory: " + rt.freeMemory());
			d = null;
//			rt.gc();
//			System.out.println("After GC memory: " + rt.freeMemory());
		}
		
		System.out.println("After free memory: " + rt.freeMemory());
		rt.gc();
		System.out.println("After GC memory: " + rt.freeMemory());
		
	}

}
